angular.module('starter')
.controller('ticketNextCtrl', function($interval, $scope, meilvFac, $stateParams, $location, cfg) {
  $scope.order = {};
  $scope.order.num = parseInt($stateParams.num);
  $scope.order.tour_time = $stateParams.date;
  $scope.order.type = $stateParams.type;
  $scope.order.selected_price = $stateParams.price;
  $scope.order.contacts = {};

  $scope.creatRandCode = function(){
    $scope.time = 60;
    var stop = $interval(function() {
      $scope.time --;
      if($scope.time<=0){
        $interval.cancel(stop);
        stop = undefined;
      }
    }, 1000);

    meilvFac.user.sendsms({phone:$scope.order.contacts.contact_mobile}, function(){  
      
    },function(data){
      alert(data.data.info);
    });      
  }

  $scope.submit = function(){
    // if(!$scope.order.contacts.contact_name||!$scope.order.contacts.contact_mobile||!$scope.order.contacts.identity_card){
    //   alert('请填写完整联系人信息！');
    //   return;
    // }
    meilvFac.disney.orderadd($scope.order,function(data){
      window.location.href = cfg.baseUrl +'home/index/gotoPay/id/' + data.order_id;
    },function(data){
      alert(data.data.info);
    });
  };
})